package com.example.lx6_8.attend

import androidx.paging.PagingSource
import androidx.paging.PagingState
import com.example.base.aa.entity.AttendEntityItem
import com.example.base.aa.net.ApiService

class AttendSource(val apiService: ApiService) : PagingSource<Int,AttendEntityItem>() {
    override fun getRefreshKey(state: PagingState<Int, AttendEntityItem>): Int? {
        return null
    }

    override suspend fun load(params: LoadParams<Int>): LoadResult<Int, AttendEntityItem> {
        try {
            val attend = apiService.getAttend(1)
            return LoadResult.Page(attend.data,null,null)
        }catch (e:Exception){
            return LoadResult.Error(e)
        }
    }

}